using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Threading;using System.IO.Ports;namespace sms{ public partial class Form1 : Form { public Form1 ( ) { InitializeComponent ( ); } private void buttonSend_Click ( object sender , EventArgs e ) { string CenterNum = "13800769500"; //短信中心 ComPortClass cp = new ComPortClass ( "COM1" , 9600 ); string ss = cp.SetMsgCenter ( CenterNum ); MessageBox.Show ( ss ); string s2 = cp.SendToCom ( "13763170048" , CenterNum , "测试一下,麻烦您收到信息请告之我!" ); MessageBox.Show ( s2 ); } private void button_read_Click ( object sender , EventArgs e ) { ComPortClass cp = new ComPortClass ( "COM1" , 9600 ); //有些类型的短信,好像读出出来,手机给手机发的短信可以读取 for ( int i = 1; i < 10 ; i ) { string s2 = cp.ReadMsg ( i.ToString ( ) ); MessageBox.Show ( i.ToString ( ) Environment.NewLine s2 ); } } }}
评论